<?php

/**
 * This is the model class for table "mall_goods_specs".
 *
 * The followings are the available columns in table 'mall_goods_specs':
 * @property string $goods_id
 * @property string $specs_id
 * @property string $specs_name
 * @property integer $specs_type
 * @property string $attrs_id
 * @property string $attrs_name
 * @property string $unit_id
 * @property string $unit_name
 * @property string $value
 * @property string $pic_url
 * @property string $ext1
 * @property string $ext2
 * @property integer $sort
 * @property string $create_time
 * @property string $update_time
 * @property string $created_by
 * @property string $updated_by
 * @property integer $is_delete
 */
class MallGoodsSpecs extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return MallGoodsSpecs the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'mall_goods_specs';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('goods_id, specs_id', 'required'),
			array('specs_type, sort, is_delete', 'numerical', 'integerOnly'=>true),
			array('goods_id, attrs_id, unit_id', 'length', 'max'=>64),
			array('specs_id', 'length', 'max'=>20),
			array('specs_name, attrs_name, unit_name, value, ext1, ext2, created_by, updated_by', 'length', 'max'=>255),
			array('pic_url, create_time, update_time', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('goods_id, specs_id, specs_name, specs_type, attrs_id, attrs_name, unit_id, unit_name, value, pic_url, ext1, ext2, sort, create_time, update_time, created_by, updated_by, is_delete', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'goods_id' => 'Goods',
			'specs_id' => 'Specs',
			'specs_name' => 'Specs Name',
			'specs_type' => 'Specs Type',
			'attrs_id' => 'Attrs',
			'attrs_name' => 'Attrs Name',
			'unit_id' => 'Unit',
			'unit_name' => 'Unit Name',
			'value' => 'Value',
			'pic_url' => 'Pic Url',
			'ext1' => 'Ext1',
			'ext2' => 'Ext2',
			'sort' => 'Sort',
			'create_time' => 'Create Time',
			'update_time' => 'Update Time',
			'created_by' => 'Created By',
			'updated_by' => 'Updated By',
			'is_delete' => 'Is Delete',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('goods_id',$this->goods_id,true);
		$criteria->compare('specs_id',$this->specs_id,true);
		$criteria->compare('specs_name',$this->specs_name,true);
		$criteria->compare('specs_type',$this->specs_type);
		$criteria->compare('attrs_id',$this->attrs_id,true);
		$criteria->compare('attrs_name',$this->attrs_name,true);
		$criteria->compare('unit_id',$this->unit_id,true);
		$criteria->compare('unit_name',$this->unit_name,true);
		$criteria->compare('value',$this->value,true);
		$criteria->compare('pic_url',$this->pic_url,true);
		$criteria->compare('ext1',$this->ext1,true);
		$criteria->compare('ext2',$this->ext2,true);
		$criteria->compare('sort',$this->sort);
		$criteria->compare('create_time',$this->create_time,true);
		$criteria->compare('update_time',$this->update_time,true);
		$criteria->compare('created_by',$this->created_by,true);
		$criteria->compare('updated_by',$this->updated_by,true);
		$criteria->compare('is_delete',$this->is_delete);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}